package com.springhone.side.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.springhone.side.domain.Joke;
import com.springhone.side.service.JokeService;

@Controller
@RequestMapping("joke")
public class JokeController {

    private JokeService jokeService;

    @RequestMapping(value = "add", method = RequestMethod.GET)
    public String addJoke() {
        Joke joke = new Joke();
        joke.setJokeTitle("joke title");
        joke.setJokeContent("joke Content");
        if(jokeService != null) {
            jokeService.create(joke);
        } else {
            System.out.println("aaaa");
        }
        return "joke/list";
    }

    @Autowired
    public void setJokeService(JokeService jokeService) {
        this.jokeService = jokeService;
    }

}
